﻿<!DOCTYPE HTML>
<html>
<head>
	<!--#header start-->
	{include file="public/_meta" /}
	<!--#header end-->
<title>角色管理</title>
</head>
<body>
<nav class="breadcrumb">
	<i class="Hui-iconfont">&#xe67f;</i> 首页
	<span class="c-gray en">&gt;</span> 管理员管理
	<span class="c-gray en">&gt;</span> 角色管理
	<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
 </nav>
<div class="page-container">
	<div class="cl pd-5 bg-1 bk-gray">
		 <span class="l">
			  <a href="javascript:;" onclick="datadel()" class="btn btn-danger radius">
					<i class="Hui-iconfont">&#xe6e2;</i>
					批量删除
				</a>
			  <a class="btn btn-primary radius" href="javascript:;" onclick="admin_role_add('添加角色','{:url('Auth/createGroup')}','800')">
				 <i class="Hui-iconfont">&#xe600;</i>
				  添加角色
				</a>
			</span>
			<!-- <span class="r">共有数据：<strong>3</strong> 条</span>  -->
	</div>
	<table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<tr>
				<th scope="col" colspan="7">角色管理</th>
			</tr>
			<tr class="text-c">
				<th width="25"><input type="checkbox" value="" name="id[]"></th>
				<th width="40">ID</th>
				<th width="100">角色名</th>
				<th width="200">是否为最高权限管理者</th>
				<th >用户列表</th>
				<th width="300">备注</th>
				<th width="200">操作</th>
			</tr>
		</thead>
		<tbody>
     	{volist name="groupList" id="list"}
				<tr class="text-c">
					<td><input type="checkbox" value="{$list.id}" name="id[]"></td>
					<td>{$list.id}</td>
					<td>{$list.title}</td>
					<th>
						{if condition="$list.is_admin"}
						<a href="javascript:;"><span class="label label-secondary radius">是</span></a>
						{else /}
						<a href="javascript:;"><span class="label label-warning radius">否</span></a>
						{/if}
					</th>
					<td>
						<a href="#" class="label label-default radius ml-5">超级管理员</a>
						<a href="#" class="label label-default disabled radius ml-5">1297942619@qq.com</a>
						<a href="#" class="label label-default disabled radius ml-5">myTTYY</a>
					</td>
					<td>{$list.remark}</td>
					<td class="f-14">
						{if condition="$list.is_admin"}
						  <a class="btn btn-warning-outline radius size-MINI" href="javascript:;">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
              <a class="btn btn-danger-outline radius size-MINI" href="javascript:;">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						{else /}
							<a class="btn btn-warning-outline radius size-MINI" title="编辑" href="javascript:;" onclick="admin_role_edit('角色编辑','{:url('Auth/editGroup')}?id={$list.id}','{$list.id}')" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6df;</i>
							</a>
							<a class="btn btn-danger-outline radius size-MINI" title="删除" href="javascript:;" onclick="admin_role_del(this,'{$list.id}')" style="text-decoration:none">
								<i class="Hui-iconfont">&#xe6e2;</i>
							</a>
						{/if}
					</td>
				</tr>
			{/volist}
		</tbody>
	</table>
</div>

<!--#header start-->
{include file="public/_footer" /}
<!--#header end-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="__ADMIN__/lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript">
/*管理员-角色-添加*/
function admin_role_add(title,url,w,h){
	layer_show(title,url,w,h);
}
/*管理员-角色-编辑*/
function admin_role_edit(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*管理员-角色-删除*/
function admin_role_del(obj,id){
	layer.confirm('角色删除须谨慎，确认要删除吗？',function(index){
		$.ajax({
			type: 'DELETE',
			url: "{:url('Auth/deleteGroup')}",
			data:{id:id},
			dataType: 'json',
			success: function(data){
				if(data.state){
					$(obj).parents("tr").remove();
					layer.msg(data.msg,{icon:1,time:1000});
				}else {
					layer.msg(data.msg,{icon:5,time:1000});
				}
			},
			error:function(data) {
				console.log(data.msg);
				console.log(data.state);
			},
		});
	});
}

/*管理员-批量删除*/
function datadel(obj){
	var chk_value =[];
	$('input[name="id[]"]:checked').each(function(){
		chk_value.push($(this).val());
	});
	if (chk_value.length==0 ) {
		layer.msg('未选中任意项', {icon: 5,time:1000});
	}else {
		$.ajax({
			type: 'DELETE',
			url: "{:url('Auth/allDelete')}",
			data:{id:chk_value},
			dataType: 'json',
			success: function(data){
					if(data.state){
						layer.msg(data.msg,{icon:1,time:1000});
					}else {
						layer.msg(data.msg,{icon:5,time:1000});
					}
			}
		});
	}

}
</script>
</body>
</html>
